package xyz.riceball.springcloudstreambinderfile;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import xyz.riceball.springcloudstreambinderfile.file.FileMessageChannelBinder;
import xyz.riceball.springcloudstreambinderfile.file.FileProvisioningProvider;
import xyz.riceball.springcloudstreambinderfile.property.FileExtendedBindingProperties;
import xyz.riceball.springcloudstreambinderfile.property.FileProducerProperties;

// @checkstyle:off

/**
 * <p>
 * FileMessageBinderConfiguration
 * </p>
 *
 * @author xiaovcloud
 * @since 2024/6/13 14:15
 */
@EnableConfigurationProperties(FileExtendedBindingProperties.class)
@Configuration
public class FileMessageBinderConfiguration {
	@Bean
	@ConditionalOnMissingBean
	public FileProvisioningProvider fileMessageBinderProvisioner() {
		return new FileProvisioningProvider();
	}

	@Bean
	@ConditionalOnMissingBean
	public FileMessageChannelBinder fileMessageBinder(FileProvisioningProvider fileMessageBinderProvisioner, FileExtendedBindingProperties fileExtendedBindingProperties) {
		return new FileMessageChannelBinder(null, fileMessageBinderProvisioner, fileExtendedBindingProperties);
	}


	@Bean
	public FileProducerProperties fileConsumerProperties() {
		return new FileProducerProperties();
	}
}
// @checkstyle:on
